﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenSoftStore.BusinessLogic.Bill;
using OpenSoftStore.BusinessLogic.Member;
using OpenSoftStore.Client.Common;

namespace OpenSoftStore.Client.UIL.ManageReport
{
    public partial class ReportMemberAdd : UserControl
    {
       
        private MemberLogic LgcMember;
        private static ReportMemberAdd instance;
        public static ReportMemberAdd Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new ReportMemberAdd();
                }
                return instance;
            }
        }
        public ReportMemberAdd()
        {
            LgcMember = new MemberLogic();
            InitializeComponent();
            this.Dock = DockStyle.Fill;
            dgvMemberAdd.AutoGenerateColumns = false;
            btnSearch_Click(null, null);
            SPACommon.SetDataGridStyle(dgvMemberAdd);
            SPACommon.ShowSummary(dgvMemberAdd);
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            DateTime from = dtpFrom.Value.Date;
            DateTime to = dtpTo.Value.Date.AddDays(1).AddSeconds(-1.0);
            var name = txt_name.Text;
            string where =
                 string.Format(" where (T_Member.Name like '%{0}%' or T_Member.CardId like '%{0}%' or T_Member.TelNum like '%{0}%') and T_Member.AddTime  between #{1}# and #{2}# ",name, from, to);
            dgvMemberAdd.DataSource = LgcMember.GetMemberDataTable(where);
        }

        private void btnOutput_Click(object sender, EventArgs e)
        {
            SPACommon.ExportToExcel(dgvMemberAdd, "客户增长统计");
        }
    }
}
